import requests from "./requests";
// 获取最新书籍列表
export const getNewBookList = (page) =>
  requests({
    url: `/api/getBookByNew?page=${page}`,
    method: "GET",
  });
// 获取热搜列表
export const getHotBookList = () =>
  requests({
    url: "/api/getBookByRank",
    method: "GET",
  });
//获取书籍详情
export const getBookDetail = (id) => {
  return requests({
    url: `/api/getBookById?id=${id}`,
    method: "GET",
  });
};

//添加到收藏
export const addedToCollection = (bookId) => {
  return requests({
    url: "/api/addCollection",
    method: "POST",
    data: { bookId },
  });
};
//取消收藏
export const removedFromCollection = (bookId) => {
  return requests({
    url: "/api/removeCollection",
    method: "DELETE",
    data: { bookId },
  });
};
//查看是否收藏
export const checkCollection = (bookId) => {
  return requests({
    url: "/api/checkCollection",
    method: "GET",
    data: { bookId },
  });
};
//修改书籍信息
export const updateBookInfo = (book) => {
  return requests({
    url: "/api/updateBookInfo",
    method: "POST",
    data: { ...book },
  });
};

//获取书籍分类列表
export const getClassify = () =>{
	return requests({
		url:'/api/getClassify',
		method: "GET",
	});
};
//获取书籍分类列表详情
export const getBookClassify = (classify) => {
	return requests({
		url:`/api/getBookListByClassify?classify=${classify}`,
		method: "GET",
	});
};